﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI;

namespace Acms.WebControls
{
    public class JavascriptFile : WebControl
    {
        public string Path { get; set; }

        protected override void Render(HtmlTextWriter writer)
        {
            if (this.Visible)
            {
                if (!string.IsNullOrEmpty(Path))
                {
                    string resolverPath = null;
                    if (this.NamingContainer is MasterPage)
                    {
                        resolverPath = this.Page.Master.ResolveUrl(Path);
                    }
                    else
                    {
                        resolverPath = this.Page.ResolveUrl(Path);
                    }
                    writer.Write(string.Format("<script src=\"{0}\" type=\"text/javascript\"></script>", resolverPath));
                }
            }
        }
    }
}
